package cn.tedu.ivos.repair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos.repair.pojo.dto.RepairSaveParam;
import cn.tedu.ivos.repair.pojo.vo.RepairVO;
import cn.tedu.ivos.repair.service.RepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/repair")
public class RepairController {
    @Autowired
    private RepairService repairService;

    @GetMapping("select")
    public JsonResult selectRepair(RepairQuery repairQuery){
        log.debug("查询维修单记录:repairQuery={}",repairQuery);
        List<RepairVO> list = repairService.selectRepair(repairQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult savaRepair(RepairSaveParam repairSaveParam){
    	log.debug("保存维修单记录:repairSaveParam={}",repairSaveParam);
    	repairService.savaRepair(repairSaveParam);
    	return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    public JsonResult deleteRepair(@PathVariable Long id){
        log.debug("删除维修单记录:id={}",id);
        repairService.deleteRepair(id);
        return JsonResult.ok();
    }
}
